package com.cz.nongyetongv5.bean;

import java.io.Serializable;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

import android.widget.Toast;

import com.cz.nongyetongv5.utils.CharsetUtil;

public class YangPin implements Serializable {

	private String id;

	private YangPinBianHao bianHao = null;

	private String name="";
	public ArrayList<Photo> getPhotos() {
		return photos;
	}

	/**
	 * 获得上传的photo
	 *
	 * @return
	 */
	public  Photo  getUploadPhoto() {

		Photo  photos = null;

		if (this.photos != null) {

			for (Photo photo : this.photos) {

				if (photo.isUpload()) {
					photos= new Photo();
					photos=photo;

				}
			}
		}

		return photos;

	}
	private ArrayList<Photo> photos=new ArrayList<Photo>();
	public void setPhotos(ArrayList<Photo> photos) {
		this.photos = photos;
	}
	private String locale;
	//产品类别
	private int kind=0;
	public int getKind() {
		return kind;
	}

	public void setKind(int kind) {
		this.kind = kind;
	}

	private String jiShu;

	private String source;

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}
	private String xingHao = "-";

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {

		return name;
	}
	private String breedId;
	public void setName(String name) {
		this.name = name;
	}

	public String getLocale() {
		return locale;
	}

	public void setLocale(String locale) {
		this.locale = locale;
	}

	public String getJiShu() {
		return jiShu;
	}

	public void setJiShu(String jiShu) {
		this.jiShu = jiShu;
	}

	public String getXingHao() {
		return xingHao;
	}

	public void setXingHao(String xingHao) {
		this.xingHao = xingHao;
	}

	public YangPinBianHao getBianHao() {
		return bianHao;
	}

	public void setBianHao(YangPinBianHao bianHao) {
		this.bianHao = bianHao;
	}

	public YangPin(String id, YangPinBianHao bianHao, String name,
				   String locale, String jiShu, String xingHao) {
		this.id = id;
		this.bianHao = bianHao;
		this.name = name;
		this.locale = locale;
		this.jiShu = jiShu;
		this.xingHao = xingHao;
	}

	public YangPin() {
	}

	public boolean checkBianHao() {

		if (bianHao == null) {

			return false;
		}

		return true;
	}

	public String getBianHaoString() {

		return bianHao.getBianHaoString();

	}

	public boolean checkYangPinName() {

		if (CharsetUtil.isNotNull(name)) {

			return true;
		}

		return false;
	}

	public boolean checkLocale() {

		if (CharsetUtil.isNotNull(locale)) {

			return true;
		}

		return false;
	}

	public boolean checkJiShu() {

		if (CharsetUtil.isNotNull(jiShu)) {

			return true;
		}

		return false;
	}

	public boolean checkXingHao() {

		if (CharsetUtil.isNotNull(xingHao)) {

			return true;
		}

		return false;
	}

	@Override
	public boolean equals(Object o) {

		if (this == o) {

			return true;
		}

		if (o != null) {

			if (o instanceof YangPin) {

				YangPin yp = (YangPin) o;

				if (this.bianHao.getBianHaoString().equals(
						yp.getBianHao().getBianHaoString())) {

					return true;
				} else {
					return false;
				}

			} else {

				return false;
			}

		} else {

			return false;
		}
	}

	public String getBreedId() {
		return breedId;
	}

	public void setBreedId(String breedId) {
		this.breedId = breedId;
	}

}
